#ifndef _DDATAREADABLE_H
#define _DDATAREADABLE_H

//==============================================================================
//
//       DDataReadable - the data readable protocol in the ofc-library
//
//               Copyright (C) 2003  Dick van Oudheusden
//  
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// General Public License for more details.
//
// You should have received a copy of the GNU General Public
// License along with this program; if not, write to the Free
// Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//
//==============================================================================
// 
//  $Date: 2008-07-19 12:28:59 $ $Revision: 1.3 $
//
//==============================================================================

#include "ofc/config.h"

// The DDataReadable protocol specifies the interface for reading of data from
// a class implementing this interface.

@class DData;

@protocol DDataReadable

//
// Return the last error
//
// @return the error code (or 0)
//
- (int) error;

//
// Read a data string 
//
// @param length   the length of the data
//
// @return the (new) data string
//
- (DData *) readData :(unsigned long) length;

//
// Read a data string 
//
// @param dest     the destination buffer
// @param length   the length of the data (and minimum size of dest)
//
// @return the actual number of bytes read
//
- (unsigned long) readData :(unsigned char *) dest :(unsigned long) length;

//
// Read a character
//
// @return the character read (or EOS)
//
- (char) readChar;

//
// Read a byte
//
// @return the byte read (or 0)
//
- (unsigned char) readByte;

//
// Read a short
//
// @return the short read (or 0)
//
- (short) readShort;

//
// Read a long
//
// @return the long read (or 0)
//
- (long) readLong;

//
// Read double
//
// @return the double read (or 0.0)
//
- (double) readDouble;

//
// Tell the current position in the readable
//
// @return the current position
//
- (unsigned long) tell;

//
// Move the current position in the readable
//
// @param offset   the offset from the origin (in bytes)
// @param origin   the origin for the offset (0=begin, 1=current, 2=end)
//
// @return success
//
- (BOOL) seek :(unsigned long) offset :(int) origin;

//
// Skip a number of positions
//
// @param offset   the number of bytes to skip
//
// @return success
//
- (BOOL) skip :(unsigned long) offset;

//
// Is the end of the readable reached ?
//
// @return is it?
//
- (BOOL) isEof;

@end

#endif

/*============================================================================*/
